package com.derek.omeshopping.ui.classify;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.derek.omeshopping.R;
import com.derek.omeshopping.bean.classify.ClassifyLeftListViewBean;


import java.util.List;

/**
 * Created by My on 2016/10/17.
 */

public class ClassifyLeftListViewAdapter extends BaseAdapter {
    private List<ClassifyLeftListViewBean> list_left;
    private Context  context;
    private String BASEURL="http://m.ocj.com.cn/";
    public ClassifyLeftListViewAdapter(List<ClassifyLeftListViewBean> list_left,Context  context){
        this.list_left=list_left;
        this.context=context;
    }
    @Override
    public int getCount() {
        return list_left.size();
    }

    @Override
    public Object getItem(int position) {
        return list_left.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        viewHolder holder=null;
        if(convertView==null){
            convertView=LayoutInflater.from(context).inflate(R.layout.fragment_classifyleftlistview_item,null);
            holder=new viewHolder();
            holder.iv_remark= (ImageView) convertView.findViewById(R.id.iv_classify_leftlistview_item);
            holder.tv_code_name= (TextView) convertView.findViewById(R.id.tv_classify_leftlistview_item);
            convertView.setTag(holder);
        }else{
            holder= (viewHolder) convertView.getTag();
        }
        holder.tv_code_name.setText(list_left.get(position).getCode_name());
        Glide.with(context).load(BASEURL+list_left.get(position).getRemark()).into(holder.iv_remark);
        return convertView;
    }
    static class viewHolder{
        TextView tv_code_name;
        ImageView iv_remark;
    }
}
